<template>
	<view class="wrap">
		<view class="none" v-if="productsList.length==0">暂无该类别商品~</view>
		<view v-else>
			<uni-grid :column="2" :showBorder="false" :square="false">
				<uni-grid-item class="lisitem" v-for="(item,index) in productsList" :key="index">
					<view @click="Godetails(item.bh)">
						<image class="img" :src="item.xhtp" mode=""></image>
						<view class="text">{{item.xhmc}}</view>
						<view class="bottom">
							<view class="price">￥{{item.xhyjjg}}</view>
							<view class="sum">已销售&nbsp;{{item.xhxl}}&nbsp;件</view>
						</view>
					</view>
				</uni-grid-item>
			</uni-grid>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bh: '',
				productsList: ''
			}
		},
		onLoad(optons) {
			this.bh = optons.bh
			this.GetData()
		},
		methods: {
			// 商品列表/mall/goods/goodsList?xhzlbh=鲜花种类编号
			// goodsDetails  bh  lyj

			GetData() {
				this.requestfs({
					url: '/mall/goods/goodsList?xhzlbh=' + this.bh
				}).then(res => {
					if (res.data.msg == "success") {
						// if (res.data.data.length == 0) {
						// 	this.productsList = "暂无该类别商品~"
						// } else {
							this.productsList = res.data.data
						// }
					}
				})
			},
			Godetails(bh) {
				uni.navigateTo({
					url: '/pages-classify/productsdetails/productsdetails?bh='+bh
				})
			}
		}
	}
</script>

<style lang="scss">
	.wrap {
		background: #f3f5f7;
		min-height: 100vh;
		height: auto;
		width: 750rpx;
		padding-top: 20rpx;
		.none{
			width: 100%;
			text-align: center;
			line-height: 600rpx;
			color: #71797f;
		}

		.lisitem {
			background: #ffffff;
			width: 46%;
			margin: 0 2% 20rpx 2%;
			border-radius: 10rpx;

			.bottom {
				margin: 0 10rpx 10rpx 10rpx;

				.price {
					width: 50%;
					color: #ef5e25;
					font-weight: bold;
				}

				.sum {
					font-size: 22rpx;
					margin-top: 6rpx;
					color: #71797f;
				}
			}

			.text {
				line-height: 40rpx;
				font-size: 28rpx;
				margin: 10rpx;
				padding: 0 6rpx 0 2rpx;
				overflow: hidden; //超出部分隐藏
				text-overflow: ellipsis; //文字隐藏部分显示省略号
				display: -webkit-box; //改变盒子模型
				-webkit-line-clamp: 1; //文字显示几行
				-webkit-box-orient: vertical;
			}

			.img {
				width: 92%;
				height: 350rpx;
				border-radius: 10rpx;
			}
		}

		.title {
			display: flex;
			width: 100%;
			height: 100rpx;
			line-height: 100rpx;
			font-size: 32rpx;
			// padding-left: 40%;
			color: #ef5e25;
		}


	}
</style>
